package com.black.aidl.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

import androidx.annotation.Nullable;

import com.black.aidl.IMyIPCInterface;
import com.black.aidl.User;

public class AidlService extends Service {

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
//        return null;
//    }
        return new MyBinder();
    }

    static class MyBinder extends IMyIPCInterface.Stub {

        @Override
        public String writeAndReadName(String name) throws RemoteException {
            name = "Bob";
            return name;
        }

        @Override
        public int writeAndReadAge(int age) throws RemoteException {
            age++;
            return age;
        }

        @Override
        public User writeAndReadUser(User user) throws RemoteException {
            user.setName("Bob");
            return user;
        }
    }
}
